package org.xiji.Prototype2;

/**
 * 原型模式测试类
 */
public class Prototype2 {
    public static void main(String[] args) throws CloneNotSupportedException {


        StudentC xiji = new StudentC("惜己", 18);
        System.out.println("xiji.name = " + xiji.getName());
        System.out.println("================================");
        //通过Cloneable实现克隆方法
        System.out.println("通过java字节流实现克隆方法");
        StudentC cloneS = xiji.cloneByStream();

        System.out.println("cloneS.name = " + cloneS.getName());

        System.out.println("判断两个对象是否相等");
        System.out.println(xiji.equals(cloneS));

        System.out.println("================================");

        //通过创建对象的方法克隆对象
        System.out.println("通过创建对象的方法克隆对象");
        StudentC studentC = xiji.cloneByNew();
        System.out.println("studentC.name = " + studentC.getName());

        System.out.println("判断两个对象是否相等");
        System.out.println(xiji.equals(studentC));
        System.out.println("================================");
        //通过Cloneable类型实现克隆方法
        System.out.println("通过Cloneable类型实现克隆方法");
        StudentC cloneable = xiji.cloneByCloneable();
        System.out.println("cloneable.name = " + cloneable.getName());
        System.out.println("判断两个对象是否相等");
        System.out.println(xiji.equals(cloneable));

    }
}
